package com.example.httpmessageconverter.controller;

import com.example.httpmessageconverter.entity.DemoObj;
import com.example.httpmessageconverter.entity.TypeEnum;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/user")
public class UserController {
    @PostMapping("/name")
    public String name(@RequestBody String name) {
        System.out.println(name);
        return name;
    }

    @GetMapping("/name")
    public String name2(String name) {
        System.out.println(name);
        return name;
    }

    //接收字符串转化为对象，然后把对象又转化为字符串输出。
//    @PostMapping(value="/convert",produces = {"application/x-wisely"})
    @PostMapping(value="/convert")
    public DemoObj convert(@RequestBody DemoObj demoObj){
        DemoObj demoObj2 = new DemoObj(1L, "2");
        demoObj2.setType(TypeEnum.LOGIN);
        return demoObj2;
    }
}
